home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
demodisks
/
drives
/
1581-demo.lzh
/
burst subs.src
< prev
next >
Wrap
Text File
|
1994-10-19
|
21KB
|
24 lines
;************************************************************************
;**
;* ------------------ *
;* ---------------------- BURST SUBROUTINES ---------------------- *
;* ------------------*
;**
;* These assembly language routines are provided for your convenience. *
;* For most users, the BURST commands are very cryptic, requiring you *
;* to write your own assembly language programs to make use of them. *
;* The set of assembly language subroutines provided in this listing *
;* are designed to allow anyone to make use of the BURST routines very *
;* easily. A BASIC program needs simply to POKE the appropriate values *
;* into the variable locations shown below, and then SYS to the desired *
;* routine. All of the BURST protocol and handshaking is done for you. *
;* The BASIC program can then PEEK any values returned. *
;**
;* The routines in this listing that require data buffer storage areas *
;* are passed the location of the buffer in BUFLOC. BUFLOC points to *
;* RAM location in RAM bank 0 of the start of the buffer. Since the *
;* KERNEL and I/O are needed, RAM exists only up to $C000. So, you are *
;* free to use any RAM past your BASIC text program, up to $C000 (BASIC *
;* text normally starts at $1C00. If bit-map graphics are enabled, *
;* then BASIC text starts at $4000). If you want to PEEK and POKE this *
;* memory from BASIC, be sure to execute the 'BANK 0' command. This *
;* tells BASIC to PEEK and POKE to the RAM under the BASIC ROMs. *
;* If you want to make your program real intelligient, there are *
;* pointers to the beginning and end of BASIC text ($002D and $1210, *
;* respectively). As a general rule, work your way back from $C000, *
;* and you'll be OK.*
;**
;* To use these routines, your BASIC program must BLOAD the file *
;* 'BURST SUBS.BIN' before they can be used. They load at $1300, so *
;* they are in a safe place below BASIC text area.*
;**
;* There is no BURST FORMAT routine provided. BURST formats can be *
;* accomplished easily from BASIC. For example, the following BASIC *
;* commands will format physical tracks 10 through 20 of the disk with *
;* 5 1024 byte sectors:*
;* *
;* OPEN 1,8,15*
;* PRINT#1,"U0";CHR$(3);CHR$(20);CHR$(5);CHR$(10);*
;**
;* Note the use of the semicolon (;) at the end of the statement. This *
;* is very important! If there was no semicolon, the C128 would *
;* send a carriage return after the last parameter. Since the 1581 *
;* counts the number of bytes sent to determine the number of optional *
;* parameters that are being sent, it would misinterpret the carriage *
;* return as the next optional parameter. In this case, it would be *
;* fill byte. Any formatting errors can be checked via the command *
;* channel.*
;**
;* Since the BURST commands make use of the command channel to the *
;* drive, the command channel must first be OPENed in your BASIC *
;* program. The logical file number which you assigned to the command *
;* channel should be poked to LF before calling any of these routines. *
;**
;************************************************************************
;************************************************************************
; Variables - Values from BASIC can be POKEd, PEEKed to these areas.
;************************************************************************
*=$1300
STATUS .byte 0; status byte
DEV.byte 8; device number
LF .byte 8; logical file number
TRACK*=*+1; track
SECTOR *=*+1; sector
NUMSEC*=*+1; Number of sectors.
BUFLOC*=*+2; Page # of buffer to get/put data.
SECSIZE*=*+1; Sector size (1=256, 2=512, 4=1024)
SIDE*=*+1; Physical side of the disk (0 or 1).
MINSEC *=*+1; Minimum logical sector found in QUERY.
MAXSEC*=*+1; Maximum logical sector found in QUERY.
INTLV*=*+1; Physical interleave found in QUERY.
FLAG *=*+1; Empty track flag.
; This flag is used to indicate that the
; track or data just read contains all 0's.
; This is handy in some cases, such as
; during a disk copy program. When a disk
; is formatted, the sectors are filled with
; 0's. If a sector to be copied contains
; all 0's, then we don't bother to
; write it to the destination disk (which
; can end up saving a great deal of time!).
;*************************************************************************
; Other variables used in the following routines....
;*************************************************************************
cmdline
.byte 'u0'; Burst prefix.
*=*+10; Parameter space for burst command.
cmdlen*=*+1; Length of the command string (# of bytes).
oldclk *=*+1; Status of clock line.
temp*=*+1
*=$1335
.byte 'greg berlin'; Written by Greg Berlin, 3/87
;**************************************************************************
; JUMP TABLE of available burst routines. SYS to these locations from
; BASIC. The BURST routines themselves can then be modified or customized
; without affecting the SYS locations from BASIC.
;**************************************************************************
*=$1340
J_INQUIRE_FORMAT
jmp INQUIRE_FORMAT
J_PHYSICAL_READ
jmp PREAD
J_LOGICAL_READ
jmp LREAD
J_PHYSICAL_WRITE
jmp PWRITE
J_LOGICAL_WRITE
jmp LWRITE
J_MEMORY_READ
jmp MEMORY_READ
J_MEMORY_WRITE
jmp MEMORY_WRITE
J_DUMP_CACHE
jmp DUMP_CACHE
J_QUERY_FORMAT
jmp QUERY_FORMAT
J_COMPARE_MEMORY
jmp COMPARE_MEMORY
;**************************************************************************
; Locations of important C128 stuff...
;**************************************************************************
chkout=$ffc9; kernel channel output
clrchn=$ffcc; kernel clear channel
setlfs=$ffba; kernel set logical file number
setnam=$ffbd; kernel set filename
bsout =$ffd2; kernel basic input/output
spin_out=$ff47; Set up fast serial for input or output.
; SEC for output, CLC for input.
d2pra =$dd00; C128 serial port location
clkout=$10; slow serial clock output bit mask
clkin =$40; slow serial clock input bit mask
d1icr =$dc0d; 6526 CIA interrupt control register
d1sdr =$dc0c; 6526 CIA serial data register
buffer=$fa; zero page pointer variable
buffer2=$fc; zero page pointer variable
;**************************************************************************
; BURST command primitives
;**************************************************************************
PBURSTRD =$00; Physical burst read.
PBURSTWR =$02; Physical burst write.
LBURSTRD =$80; Logical burst read
LBURSTWR =$82; Logical burst write.
BURST_INQUIRE =$04; Burst inquire.
DUMPCACHE =$9C; Dump track cache ('force' bit set)
BURST_QUERY =$86; Query disk format.
;**************************************************************************
;* ------------------------- BURST ROUTINES ---------------------------- *
;**************************************************************************
LREAD;Logical sector read from the device indicated by LF.
;The track and sector are in TRACK, SECTOR. The location
;of start of the C128 buffer to put the read data in BUFLOC.
;Status byte from drive is returned in STATUS.
lda #lburstrd;logical burst read command
sta cmdline+2
lda #$01
sta SECSIZE;Logical sector size is always 256 bytes.
jmp READ
PREAD;Physical sector read from device indicated by LF.
;The track and sector are in TRACK, SECTOR. The location
;of start of the C128 buffer to put the read data in BUFLOC.
;The physical sector size in SECSIZE (1=256,2=512,4=1024).
;Number of sectors in NUMSEC.
;Physical side of the disk in SIDE (0 or 1).
;Status byte from drive is returned in STATUS.
lda #PBURSTRD ;Physical burst read command.
ldx SIDE; Check which side to read from.
beq 1$
ora #$10; If side 1, then set bit in the command byte.
1$sta cmdline+2
READ
lda $ff00;Save old MMU setup.
pha
lda #$0e;Set MMU for RAM0,KERNEL,I/O.
sta $ff00
jsr SETU0;Put "U0" at start of command string.
lda TRACK
sta CMDLINE+3; track
lda SECTOR
sta CMDLINE+4; sector
lda NUMSEC
sta CMDLINE+5; Number of sectors to read.
lda #$06; Length of command string.
sta CMDLEN
jsr sendcmd; send cmd string
lda BUFLOC; Set up zero page indirect pointer.
sta BUFFER
lda BUFLOC+1
sta BUFFER+1
ldy #0; clear the 'empty sector(s)' flag.
sty flag
sei; No irq's allowed during handshake.
bit d1icr; clear pending
jsr CLK_CHNG;Change state of clock.
1$ldx SECSIZE; Sector size gives # of pages per sector.
jsr WAIT;Wait for fast byte (1st is status).
lda d1sdr;Get status byte.
sta STATUS
and #15;Was there an error?
cmp #2;
bcs 5$; branch if error occured.
jsr CLK_CHNG;Change clock so next byte is sent.
3$jsr WAIT;Wait for the next byte.
jsr CLK_CHNG;Change state of clock so next byte is sent.
lda D1SDR;Get the data byte
sta (buffer),y; and save it
; while next byte is being transmitted.
ora flag;Update 'zero' sector flag.
sta flag
iny;Any more in this page?
bne 3$
inc BUFFER+1
dex;Loop for the # of pages per sector.
bne 3$
dec CMDLINE+5;Loop for the number of sectors.
bne 1$
5$cli
pla;Restore MMU to old configuration.
sta $ff00
rts
;**************************************************************************
LWRITE;Logical sector write to the device indicated by LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o
LF.
;The track and se8 $@A>i8s {$f0} X {SHIFT-*} &XB{$7c} {$f0}
F{$7c} {$f0}${$7c}FX{$e2}2&{$7c}{$e4}
DD{SHIFT-*}&{$7c} {$f0}B{$7c}
$B{$7c}L{$f0}{$f2}{$7c}X
{SHIFT-*}{$e2}{$7f}
v
@e{SHIFT-POUND}'{CBM-POUND} A)( {$7c}
{CBM-G}!d iO
@{$f0}PRoOL{$f0}RoO@d{$f2}R@oOPRoLiGFPRo
RR@o